vcMotionTarget

vcMotionTarget is a motion target for a robot, which may include joint and tool behavior as well as speed and configuration settings for orientation solutions.

See in: Overview

Module: vcRobotics

Parent: vcObject

Children -

Referenced by: vcMotionInterpolator.Targets, vcMotionInterpolator.createTarget(), vcMotionInterpolator.interpolate(), vcRobotController.createTarget()

Properties

Learn how to use properties here. The properties are also inherited from the parent class.

NameTypeAccessDescription
AccuracyMethodvcMotionAccuracyMethodRWDefines the zone of accuracy type to use for the target, for example distance, time or velocity.
AccuracyValueRealRWDefines the limit used in AccuracyMethod.
AngularSpeedRealRWDefines the rate of target rotation (degrees/s), which is only used for non-joint motions.
BaseMatrixvcMatrixRWDefines a matrix referenced by the target as robot base frame. If set, this property overrides BaseName.
BaseNameStringRWDefines base frame in robot controller referenced by the target.
CartesianAccelerationRealRWDefines the maximum Cartesian acceleration (units/s^2) of linear motion to target.
CartesianDecelerationRealRWDefines the maximum Cartesian deceleration (units/s^2) of linear motion to target.
CartesianSpeedRealRWDefines the maximum Cartesian speed (units/s) of linear motion to target.
ConfigCountIntegerRGets the number of available configurations in robot.
ConfigurationModevcMotionConfigurationModeRWDefines the robot's joint configuration during linear interpolation,
See more
which can be fixed, an attempt to maintain current configuration or one interpolated using joint values.
JointSpeedFactorRealRWDefines the joint speed at the target, as a factor of maximum speed determined in robot controller.
JointTurnModevcMotionTargetTurnRWDefines the turn mode for joints in the target.

The default mode is for joints to turn nearest within their set limits.
JointValueslist[Real]RWDefines joints values of target if using joint interpolation.
See more
To read and write joint values, first get a handle for this property, edit the values of that handle, and then assign that handle as the value of this property.
MotionTypevcMotionTypeRWDefines the motion type of the target, which is either linear or point-to-point/joint.
OrientationInterpolationModevcMatrixModeRWDefines the orientation interpolation mode for linear movement.
PositionerIndexIntegerRWDefines current positioner used by robot to reach target.
RobotConfigIntegerRWDefines robot configuration at target, which is dependent on the kinematic structure.
TargetvcMatrixRWDefines position matrix of target relative to its base frame or matrix.
TargetModevcMotionTargetModeRWDefines how position matrix of target relates to robot.
ToolMatrixvcMatrixRWDefines a matrix referenced by the target as the robot tool frame. If set, this property overrides ToolName.
ToolNameStringRWDefines tool frame in robot referenced by target.
UseJointsBooleanRWDefines if JointValues property is used to define target or its Target property.
See more
That is, whether the target is defined using joint values or a position matrix that is used to calculate joint values.

If you set JointValues, this property is automaticaly set to True.

If you set Target, this property is automatically set to False.

Methods

Learn how to use methods here. The methods are also inherited from the parent class.

NameReturn TypeParametersDescription
getConfigWarningIntegerInteger configurationTests a robot configuration for any potential issues associated with target.
See more
The returned value indicates singularity (S), joint limits (J) and unreachable (U) errors using a format of SJU.

0 = 000
No errors.

1 = 001
Reachability error in robot.

2 = 010
One or more joints exceeding limits.

3 = 011
Reachability and joint limit errors.

4 = 100
Singularity detected, for example in articulated robot wrist.

5 = 101
Singularity and reachability errors.

6 = 110
Singularity and joint limit errors.

7 = 111
Singularity, joint limit and reachability errors.

See Motion Target Constants for more information.

Parameters:
configuration (Integar): Robot configuration

Returns:
Enumeration (vcMotionConfigurationStatus)
getConfigWarningslist[Integer]NoneTests all configurations in kinematic structure for potentials errors related to target.
See more
See getConfigWarning() method for more information on possible returned values.

Returns:
List of Enumeration (vcMotionConfigurationStatus)
getPositionerRootToPositionerFlangevcMatrixNoneReturns the offset from robot positioner root node to its flange node.

Returns:
Matrix (vcMatrix)
getRobotRootToRobotFlangevcMatrixNoneReturns the offset from robot root node to robot flange node.

Returns:
Matrix (vcMatrix)
getRootNodeToPositionerRootvcMatrixNoneReturns the offset from root node to robot positioner root node.

Returns:
Matrix (vcMatrix)
getRootNodeToRobotRootvcMatrixNoneReturns the offset from root node to robot root node.

Returns:
Matrix (vcMatrix)
getSimWorldToRobotToolvcMatrixNoneReturns the offset from 3D world origin to tool frame active in robot.

Returns:
Matrix (vcMatrix)
getSimWorldToRobotWorldvcMatrixNoneReturns the offset from 3D world origin to Robot World Frame.

Returns:
Matrix (vcMatrix)
getSimWorldToRootNodevcMatrixNoneReturns the offset from 3D world origin to root node.

Returns:
Matrix (vcMatrix)

Example: Calculate Inverse Kinematics

"""Calculate inverse kinematics for given target matrix"""

import vcCore as vc
import vcBehaviors as vc_beh
import vcRobotics as vc_robo

app = vc.getApplication()
comp = vc.getComponent()


async def OnRun():
  
  ctr = comp.findBehavior(vc_beh.vcBehaviorType.ROBOT_CONTROLLER)
  base_name = ctr.Bases[0].Name
  tool_name = ctr.Tools[0].Name
  config = 0
  init_joints = [x.CurrentValue for x in ctr.Joints]
  target_matrix = vc.vcMatrix.new()
  target_matrix.P = vc.vcVector.new(800.0, 0.0, 500.0)
  target_matrix.WPR = vc.vcVector.new(0.0, 180.0, 0.0)
  
  # Solve joint values for given target
  joint_values = calc_inverse(ctr, target_matrix, base_name, tool_name, config, init_joints)
  print('Joint values: ', joint_values)
  
  # Move robot to solved joint values
  for i, j in enumerate(ctr.Joints):
    j.CurrentValue = joint_values[i]
  app.render()


def calc_inverse(controller, target_matrix, base_name, tool_name, config, init_joints):
  """Caclulate inverse kinematics using motion target"""
  
  # Create target
  motion_target = controller.createTarget()
  
  # Set base and tool
  motion_target.BaseName = base_name
  motion_target.ToolName = tool_name
  
  # Set initital joints, used to define joint turns and external axes
  motion_target.JointValues = init_joints
  
  # Set robot config
  motion_target.RobotConfig = config
  
  # Set target matrix
  motion_target.Target = target_matrix
  
  # Return joint values
  return motion_target.JointValues
  

Example: Robot Pose to Target

from vcCore import *
from vcFeatures import *
from vcGeometry import *
from vcBehaviors import *
from vcRobotics2 import *

def robot_pose_to_target(controller: vcMotionController, type: vcMotionTargetType, toolName="Null", baseName="Null") -> vcLinearTarget | vcPtpTarget | vcMultiDriverTarget:
  """Compile robot target from curen robot position, based on motion target type, tool and base data. (Excludes speed data)"""

  # Controller driver positions
  internalDriverPositions = controller.DriverPositions
  externalDriverPositions = controller.ExternalDriverPositions

  # Joint target does not require solving
  if type == vcMotionTargetType.MULTIDRIVER:
    target: vcMultiDriverTarget = controller.createTarget(type)
    target.InternalDriverValues = [(i, val) for i, val in enumerate(internalDriverPositions)]
    target.ExternalDriverValues = externalDriverPositions
    return target

  # Cartesian targets require use of kinematic solver
  if type == vcMotionTargetType.LINEAR or vcMotionTargetType.PTP:
    
    # Kinematics object for controller
    kinematics = controller.Kinematics

    # Create solver for calculating forward kinematic solution for pose
    solver = kinematics.createSolver()
    
    # Define all forvard solution related information
    solver.RootMatrix = controller.Component.WorldPositionMatrix
    solver.BaseMatrix = kinematics.findBase(baseName).PositionMatrix
    solver.ToolMatrix = kinematics.findTool(toolName).PositionMatrix
    
    # Fill in preoperties based on target type
    target: vcLinearTarget | vcPtpTarget = controller.createTarget(type)
    target.Target = solver.forward(internalDriverPositions)
    if isinstance(target, vcLinearTarget):
      target.InternalDriverValues = internalDriverPositions
    if isinstance(target, vcPtpTarget):
      target.DriverReferenceValues = internalDriverPositions
    target.ExternalDriverValues = externalDriverPositions
    
    return target
# Snippet ------------------------------------

def OnReset():
  controller: vcMotionController = getComponent().findBehaviorsByType(vcBehaviorType.ROBOTICS2_MOTIONCONTROLLER)[0]
  target = robotPoseToTarget(controller, vcMotionTargetType.LINEAR, "TOOL[1]", "BASE_2")